<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>详情</title>
    <link rel="stylesheet" href="../../../assert/css/font.css"/>
    <link rel="stylesheet" href="../../../assert/css/bootstrap.min.css">
    <link href="../../../assert/css/plugin/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="../../../assert/css/plugin/toastr/toastr.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../../../assert/css/plugin/chosen/chosen.css">
    <link href="../../../assert/css/loaders.css" rel="stylesheet">
    <link href="../../../assert/css/plugin/jsTree/themes/default/style.css" rel="stylesheet"
          th:href="@{/assert/css/plugin/jsTree/themes/default/style.css}">
    <link rel="stylesheet" href="../../../assert/css/animate.min.css" th:href="@{/assert/css/animate.min.css}"/>
    <link rel="stylesheet" href="../../../assert/css/subpagesCss/detail.css" th:href="@{/assert/css/subpagesCss/detail.css(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}">
</head>
<body>
<!--删除标签确认框-->
<div class="modal fade" id="tagDelModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">删除标签</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span>确实要删除 <span
                            id="delName"></span>吗？
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="delBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--申诉模态框-->
<div class="modal fade" id="appealModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width: 750px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">质检结果申诉</h4>
            </div>
            <div class="modal-body">
                <table id="tableAppeal"></table>
            </div>
            <div class="modal-footer">
                <span class="fa fa-info-circle" style="position: absolute;left: 15px;"
                      id="tip">&nbsp;&nbsp;提交申诉后不能再修改!</span>
                <button type="button" class="btn btn-primary" id="submitBtn">提交</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--提交申诉确认框-->
<div class="modal fade" id="submitModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="margin-top: 113px;width: 721px;">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">确认</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span>确实要提交吗？</div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="lastSubmitBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--添加质检模型框-->
<div class="modal fade" id="addModelModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width:1000px;">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">添加规则</h4>
                </div>
                <div class="modal-body" style="display: inline-block;width:100%;">
                    <!--<div class="selectModel">-->
                    <!--<div class="menu_left">-->
                    <!--<div class="search_box">-->
                    <!--<input type="text"><span class="fa fa-search fa_btn" id="searchMenu"></span>-->
                    <!--</div>-->
                    <!--<div id="jstree" class="scrollbar">-->

                    <!--</div>-->
                    <!--</div>-->
                    <!--<div class="model_right" style="width:690px;">-->
                    <!--<table id="modelTableWin"></table>-->
                    <!--</div>-->
                    <!--</div>-->
                </div>
                <!--<div class="modal-footer">-->
                <!--<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>-->
                <!--<button type="button" class="btn btn-white" id="resetModel">重置</button>-->
                <!--<button type="button" class="btn btn-primary" id="selectModel">确定</button>-->
                <!--</div>-->
            </form>
        </div>
    </div>
</div>
<!--人工质检规则确认框-->
<div class="modal fade" id="ruleCheckModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">确认</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span><span
                            id="ruleCheckName"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="ruleCheckBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--删除规则确认框-->
<div class="modal fade" id="ruleDelModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">删除规则</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span><span
                            id="delNameRule">确实要删除</span>吗？
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="delRuleBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--提交标注确认框-->
<div class="modal fade" id="bzModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="margin-top: 113px;width: 721px;">
        <div class="modal-content">
            <form method="post">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">确认</h4>
                </div>
                <div class="modal-body">
                    <div style="text-align: center"><span class="fa fa-question-circle"></span>确实要提交标注吗？</div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="bzSubmitBtn">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--头部基本信息-->
<fieldset class="base">
    <legend class="on hidden" data-title="概况">
        概况 <span class="fa fa-angle-down"></span>
    </legend>
    <div class="fieldset_box" >
        <div class="baseBox" style="overflow: hidden;height:60px;">
            <ul class="baseUl">
                <li style="width:800px;">录音流水号:<span id="audioId" style="max-width:700px;"></span></li>
            </ul>
            <ul class="baseUl">
                <li>坐席班组:<span id="seatGroup"></span></li>
                <li>坐席工号:<span id="seatWorker"></span></li>
                <li>姓名:<span id="seatName"></span></li>
                <li>客户归属地:<span id="customerloc"></span></li>
                <li>客户星级:<span id="customerLevel"></span> <i style="cursor:pointer;margin-left:15px;color: #337ab7;" id="baseChange">展开<b class="fa fa-angle-double-down"></b></i></li>
            </ul>
            <ul class="baseUl">
                <li>通话开始时间:<span id="phoneStartTime"></span></li>
                <li>通话结束时间:<span id="phoneEndTime"></span></li>
                <li>通话时长:<span id="timeDur">38</span></li>
                <li>受理号码:<span id="proPhoneNum"></span></li>
                <li>客户号码:<span id="phone"></span></li>
            </ul>
            <ul class="baseUl">
                <li>满意度:<span id="satisfaction"></span></li>
                <li>呼叫类型:<span id="callType"></span></li>
                <li>挂机方:<span id="onHook"></span></li>
                <li style="width:15%">是否重复来电:<span id="reCallFlag"></span></li>
            </ul>
        </div>
        <div class="wave_box">
            <div class="wave">
                <div class="speakerModel-player"></div>
                <div class="waveTime_one"></div>
                <div id="sp-player-wrapper">
                    <div id="sp-player-loadDiv" class="progress progress-striped active"
                         style="display:block;position: absolute;top: 54%;">
                        <div id="sp-player-loadBar" class="progress-bar progress-bar-info" role="progressbar"
                             aria-valuenow="0"
                             aria-valuemin="0" aria-valuemax="100">0%
                        </div>
                    </div>
                </div>
                <div class="btn-group-wrapper">
                    <div class="btn-group" role="group">
                        <button type="button" class="btn btn-sm" title="播放/暂停" data-action="speakerModel-play-btn"
                                onclick="wave.playPause()" id="playStopTab" style="color:#337ab7"><span
                                class="glyphicon glyphicon-play"></span>
                        </button>
                        <button type="button" class="btn btn-sm" title="停止" data-action="speakerModel-stop-btn"
                                onclick="wave.stop()"><span
                                class="glyphicon glyphicon-stop"></span></button>
                        <button type="button" class="btn btn-sm" title="快退"
                                data-action="speakerModel-skip-backward-btn"
                                onclick="wave.skipBackward(wave.skipLength)"><span
                                class="glyphicon glyphicon-backward"></span></button>
                        <button type="button" class="btn btn-sm" title="快进"
                                data-action="speakerModel-skip-forward-btn"
                                onclick="wave.skipForward(wave.skipLength)"><span
                                class="glyphicon glyphicon-forward"></span></button>
                        <button type="button" class="btn fa fa-search-minus" href="#"
                                onclick="wave.zoomAudioOut()" title="缩小波形"></button>
                        <div class="btn-group" style="width:100px;display: none;"><!-- type="range" 有step限制-->
                            <input id="myPlayer-room-input" min="1" max="100" value="1"
                                   width=100 height=22/>
                        </div>
                        <button type="button" class="btn fa fa-search-plus" href="#"
                                onclick="wave.zoomAudioIn()" title="放大波形"></button>
                        <button type="button" class="btn fa fa-dot-circle-o" href="#"
                                onclick="wave.zoomAudio()" title="全波形"></button>
                        <button type="button" class="btn btn-sm audioBtn prePhone hidden" title="上一条语音"><span
                                class="glyphicon glyphicon-arrow-up"></span></button>
                        <button type="button" class="btn btn-sm audioBtn nextPhone hidden" title="下一条语音"><span
                                class="glyphicon glyphicon-arrow-down"></span></button>

                        <span style="margin-left:20px;">语速：</span><select name="" id="audioSpeed"></select>
                        <span style="margin-left:20px;">总时长：<b id="totalTime">0</b></span>

                        <span style="margin-left:20px;">跳转到:
                            <input type="text" class="waveInput hour" placeholder="时" autocomplete="off" disabled><i class="waveText">时</i>
                            <input type="text" class="waveInput minute" placeholder="分" autocomplete="off" disabled><i class="waveText">分</i>
                            <input type="text" class="waveInput seconds" placeholder="秒" autocomplete="off" disabled><i class="waveText">秒</i>
                            <button id="jumpBtn">跳转</button>
                        </span>
                        <span style="margin-left:20px;">当前时间：<b id="nowTime">0</b></span>

                        <shiro:hasPermission name="IS_NEED_BZ">
                            <span class="needTagging" style="margin-left:20px;padding:5px 15px; background:#337ab7; color:#fff;  cursor:pointer;border:1px solid #d6d6d6;">转写需标注</span>
                        </shiro:hasPermission>
                    </div>
                </div>
            </div>
        </div>
    </div>
</fieldset>
<!--底部信息-->
<div class="detail_bottom">
    <div class="detail_left">
        <fieldset>
            <legend class="on" data-title="标签">
                <span style="margin-right:10px;">标签</span>(
                <b class="typeCode type0"></b><i>话务小结</i>
                <b class="typeCode type1"></b><i>系统 </i>
                <b class="typeCode type2"></b><i>人工 </i>
                )
                <span class="fa fa-angle-up"></span>
            </legend>
            <div class="fieldset_box">
                <shiro:hasPermission name="TAG_BTN">
                    <button class="fa-btn btn-primary noPer" title="添加标签" id="plusTag">添加标签</button>
                </shiro:hasPermission>
                <ul class="tags">

                </ul>
            </div>
        </fieldset>
        <fieldset class="audio_box" style="margin-bottom:3px">
            <legend class="on" data-title="录音内容">
                录音内容 <span class="fa fa-angle-up"></span>
            </legend>
            <div class="fieldset_box" style="padding-top: 12px;">
                <shiro:hasPermission name="P_CHECK_BTN">
                    <button class="btn btn-primary noPer" id="ppBtn">人工质检</button>
                </shiro:hasPermission>
                <ul class="stt_box scrollbar">

                </ul>
            </div>
        </fieldset>
    </div>
    <div class="detail_right">
        <fieldset style="margin-bottom:3px;display:none" class="tab1 animated flipInY">
            <legend class="on" data-title="添加规则">
                添加规则 <span class="fa fa-angle-up"></span>
            </legend>
            <div class="fieldset_box">
                <div class="selectModel">
                    <div class="menu_left" style="width:140px;">
                        <div id="jstree" class="scrollbar" style="min-height: 100px;">

                        </div>
                    </div>
                    <div class="model_right" style="float:right;">
                        <div class="search_box">
                            <input type="text" style="width:280px;" placeholder="规则名称"><span class="fa fa-search fa_btn" id="searchMenu"></span>
                        </div>
                        <table id="modelTableWin"></table>
                        <div class="rule_footer">
                            <button type="button" class="btn btn-white" id="closeRule">关闭</button>
                            <!--<button type="button" class="btn btn-white" id="resetModel">重置</button>-->
                            <button type="button" class="btn btn-primary" id="selectModel">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset style="margin-bottom:3px;" class="tab2">
            <legend class="on" data-title="">
                <span id="taskName"></span><span id="modelName"></span><span class="fa fa-angle-up"></span>
            </legend>
            <div class="fieldset_box">
                <ul class="rules">
                    <li id="total">分值：<span></span></li>
                    <li id="ruleHit">规则命中量：<span></span></li>
                    <li id="lethality">致命性：<span></span></li>
                    <li id="noLethality">非致命性：<span></span></li>
                    <shiro:hasPermission name="NLP_RETURN_CODE">
                        <li id="errorTip"><span></span></li>
                    </shiro:hasPermission>
                </ul>
                <div class="btns">
                    <button class="btn btn-primary" id="appealAllBtn" style="display: none;">提交申诉<span
                            class="badge detail-badge">0</span></button>
                    <!--<button class="btn btn-primary" id="ppEndBtn" style="display: none;">人工质检完成<span-->
                    <!--class="badge detail-badge">0</span></button>-->
                </div>
                <div class="table_box scrollbar">
                    <table id="table"></table>
                </div>
            </div>
        </fieldset>
    </div>
</div>
<!--需要标注模态框-->
<div class="modal" id="needtagModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title">转写需标注</h4>
                </div>
                <div class="modal-body">
                    <div class="del-question" style="text-align: center">
                        <span class="glyphicon glyphicon-exclamation-sign"></span>
                        确定转写需标注？
                    </div>
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button" class="btn btn-primary" id="needtagSave">确定</button>
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:text="${workId}" id="workId" class="hidden"></div>
<div th:text="${serialNumber}" id="serialNumber" class="hidden"></div>
<div th:text="${userIdentity}" id="userIdentity" class="hidden"></div>
<div id="proStatus" class="hidden"></div>
<div id="workName" class="hidden"></div>
<input type="text" id="classify" class="hidden">
<input type="text" id="proSelectModal" class="hidden">
<input type="text" id="modelS" class="hidden">
<input type="text" id="ruleS" class="hidden">
<input type="hidden" id="tagId" value="" class="form-control search_input">
<input type="hidden" id="areaId" value="" class="form-control search_input">
<input type="hidden" id="tagType" value="" class="form-control search_input">
<a id="basePath" th:href="@{/}"></a>
<script src="../../../assert/js/jquery.js"></script>
<script src="../../../assert/js/base.js"></script>
<script src="../../../assert/js/wavesurfer.min.js"></script>
<script src="../../../assert/js/plugin/wavesurfer.timeline.min.js"></script>
<script src="../../../assert/js/plugin/wavesurfer.regions.min.js"></script>
<script src="../../../assert/js/bootstrap.min.js"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table.min.js"></script>
<script src="../../../assert/js/plugin/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="../../../assert/js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="../../../assert/js/plugin/toastr/toastr.min.js"></script>
<script src="../../../assert/js/common.js"></script>
<script src="../../../assert/js/plugin/chosen/chosen.jquery.js"></script>
<script src="../../../assert/js/plugin/jsTree/jstree.min.js"></script>
<script src="../../../assert/js/colResizable-1.6.min.js"></script>
<script src="../../../assert/js/jquery.mousewheel.js"></script>
<script src="../../../assert/js/changeTime.js"></script>
<script src="../../../assert/js/detailCommon.js" th:src="@{/assert/js/detailCommon.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script>
    // 获取任务基本信息
    var getData = {//根据id查询单条详情信息
        jumpType:"",
        init: function () {
            getData.getWorkName();
            getData.getWorkStatusAll();
            getData.getJumpSource();//获取跳转来源
        },
        getWorkName: function () {
            var id = $("#workId").text();
            $.ajax({
                type: "post",
                url: basePath + "/rest/per-task/get-task-by-id",
                data: {
                    id: id
                },
                async: false,
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        var dataOne = data.data;
                        if (dataOne && dataOne.workname) {
                            $("#workName").text(dataOne.workname);
                            $("#taskName").html("质检任务：" + $("#workName").html());
                        }
                    } else {
                        toastrCog.error(data.msg, 3000)
                    }
                }
            })
        },
        getWorkStatusAll: function () {
            var workId = $("#workId").text();
            var serialNumber = $("#serialNumber").text();
            $.ajax({
                type: "post",
                url: basePath + "/rest/pending-task-detail/get-work-status-bu-id",
                data: {
                    workId: workId,
                    serialNumber: serialNumber,
                },
                async: false,
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        $("#proStatus").text(data.data);
                        var text=$("#proStatus").text();
                        if ($("#userIdentity").text() ==0){//坐席
                            $("#tip").show();
                            if(text%10 == 7 || text == 20) {
                                $("#appealAllBtn").hide();
                            }else{
                                $("#appealAllBtn").show();
                            }
                            $("#ppBtn").hide();//如果是坐席不显示人工质检按钮
                        }else{//非坐席
                            $("#tip").hide();
                            if(text == 20){
                                $("#appealAllBtn").show();
                            }else{
                                $("#appealAllBtn").hide();
                            }
                            if(text%10 == 7) {
                                $("#ppBtn").hide();
                            }else{
                                $("#ppBtn").show();
                            }
                            // if(text ==27 || text==37){//如果复检过期则不显示人工质检按钮
                            //
                            // }else{
                            //     if($("#ppBtn").length!=0){
                            //         $("#appealAllBtn").show().html('完成复检<span class="badge detail-badge">0</span>');
                            //     }
                            // }
                        }
                    }
                }
            })
        },
        getJumpSource:function(){
            var href= window.location.href;
            if(href.indexOf("jumpType=audio")>-1){
                getData.jumpType="audio"
            }
        }
    };
    // 页面元素宽高自适应
    var resize = {
        init: function () {
            resize.me();
            $(window).resize(function () {
                resize.me();
            })
        },
        me: function () {
            var winW = $(window).width();
            var winH = $(window).height();
            var tabW = $(".detail_right").width();
            $(".baseUl li span").each(function(){
                $(this).css({"maxWidth":($(this).parent("li").width()-135)+"px"});
            });
            $(".speakerModel-player").width(winW - 40);
            $("#sp-player-loadDiv").width(winW - 40);
            $("#modelTableWin").width(tabW - 195);
            $(".stt_box").height(winH - 260 - $('.tags').height()-95);
            $("#jstree").height(winH - 260 - 12-3-30);
            $(".detail_right .model_right").width($(".detail_right .selectModel").width()-150);
            if ($("#appealAllBtn").css("display") == "none") {
                $(".table_box").height(winH - 260 - 42 - 20-3);
            } else {
                $(".table_box").height(winH - 260 - 42 - 35 - 9-3);
            }
            $(".tab1 .fixed-table-body").css("maxHeight",(winH - 260 - 163)+"px");
            $(".tab1 .fixed-table-body").css("maxWidth",($(".detail_right").width()- 175-3)+"px");
            $("#tagModal .fixed-table-body").css("maxHeight",430+"px");
            $(".tab1 .fixed-table-body").css("minHeight","200px");
            $(".table_box").css("minHeight",(winH - 260 - 100)+"px");
        }
    };
    // 规则相关信息
    var tools = {
        scoreTotal: 0, //总分值
        ruleTimesTotal: 0, //总命中量
        fateful: 0, //致命性
        noFateful: 0, //非致命性
        nlpErrorArr:[], //语义错误回调信息
        init: function () {
            //获取总分值
            tools.getScore();
            //获取语义错误回调信息
            tools.nlpErrorArr = bs.getStatus("nlp_return_code");
            tools.getNlpError();
        },
        getScore:function(){
            $.ajax({
                type: "post",
                url: basePath + "/rest/pending-task-detail/get-workScore-serialNumber",
                dataType: "json",
                data: {
                    serialNumber: $("#serialNumber").html(),
                    workId: $("#workId").html(),
                    taskType:""
                },
                success: function (data) {
                    if (data.code == 0) {
                        $("#total span").html(data.data);
                    }
                }
            })
        },
        getNlpError:function(){
            $.ajax({
                type: "post",
                url: basePath + "/rest/task-audio-search/audio-nlp-status",
                dataType: "json",
                data: {
                    serialNumber: $("#serialNumber").html(),
                    workId: $("#workId").html(),
                    type:"work"
                },
                success: function (data) {
                    if (data.code == 0) {
                        var res = data.data;
                        if(res == null){
                            res = ''
                        }
                        $("#errorTip span").html(bs.getXInY(tools.nlpErrorArr,'name','value',res));
                    }
                }
            })
        }
    };
    var rule = {
        selectRuleArr: [],
        hasRuleArr: [],
        appealData: [],
        ruleAllData:0,
        saveRuleData:[],
        editHtml:{
            html:"",
            id:""
        },
        userMsgArr:[],
        isOpen:false,
        updataSaveData:function(obj){
            for(var i=0;i<rule.saveRuleData.length;i++){
                var ruleId= rule.saveRuleData[i].ruleId;
                var ruleDetail= rule.saveRuleData[i].ruleDetails;
                if(obj.ruleId==ruleId){
                    for(var j=0;j<ruleDetail.length;j++){
                        var detailNum=ruleDetail[j].detailNum;
                        if(obj.detailNum==detailNum){
                            ruleDetail[j].appealNote=obj.appealNote;
                            ruleDetail[j].proNote=obj.proNote;
                            if(obj.proStatus !==undefined ||obj.proStatus !=null){
                                ruleDetail[j].proStatus=obj.proStatus;
                            }
                        }
                    }
                }
            }
        },
        getState: function (value) {
            var str = "";
            if (value == 0) {
                str = "未申诉"
            } else if (value == 1) {
                str = "已申诉"
            } else if (value == 2) {
                str = "申诉成功"
            } else if (value == 3) {
                str = "申诉驳回"
            } else if (value == 4) {
                str = "已添加到申诉列表"
            } else if (value == 5) {
                str = "已添加到复检列表"
            }
            return str;
        },
        init: function () {
            var oTable = new TableInit();
            oTable.Init();
            var oTable1 = new TableInit1();
            oTable1.Init();
            rule.ruleDblclick();
            rule.appeal();
            rule.appealAll();
            rule.submitAppeal();
            rule.personTest();
            rule.delRuleOne();
            rule.resetRuleSearch();
            rule.closeRule();
            $("#table").on("click", ".backBtn", function () {
                var li = $(this).parents("li");
                var datail=JSON.parse(li.attr("data-detail"));
                datail.ruleId=li.attr("data-ruleId");
                datail.detailNum=li.attr("data-detailNum");
                datail.appealNote=li.find(".appealRemark input").val();
                datail.proNote=li.find(".proRemark input").val();
                rule.delAppeal(datail);
                li.find(".appealBtn").show();
                $(this).hide();
            });
            $("#table").on("click", ".detail", function () {
                var i=$(this).find("i");
                var a=$(this).find("a");
                var glyphicon="";
                if(i.hasClass("glyphicon-chevron-down")){
                    rule.isOpen=true;
                    glyphicon="glyphicon-chevron-down";
                }else{
                    rule.isOpen=false;
                    glyphicon="glyphicon-chevron-up";
                }
                $("#table tbody tr").each(function(){
                    var icon=$(this).find(".detail-icon");
                    var iElem=icon.find("i");
                    if(iElem.hasClass(glyphicon)){
                        icon.click();
                    }
                })
            });
        },
        ruleDblclick: function () {
            $('#table').on("click", ".ruleTime", function (event) {
                var sTime = parseFloat($(this).attr('data-sTime'));
                var eTime = parseFloat($(this).attr('data-eTime'));
                if (sTime!=null && eTime!=null) {
                    wave.playRegion(sTime, eTime);
                }
            });
        },
        appeal: function () {
            $("#table").on("click", ".appealBtn", function () {
                var $this = $(this);
                var li = $(this).parents("li");
                var b = li.find("b");
                var detail = JSON.parse(li.attr("data-detail"));
                var appealVal = li.find(".appealRemark input").val().trim();
                var proVal = li.find(".proRemark input").val().trim();
                var ruleId = li.attr("data-ruleId");
                var ruleName = li.attr("data-ruleName");
                var useFor = li.attr("data-useFor");
                var proStatus = detail.proStatus;
                var proNote = detail.proNote;
                var appealNote = detail.appealNote;
                var modelId = detail.modelId;
                var codeState = $(this).attr("data-code");
                var voiceSegments = detail.voiceSegments;
                var detailNum = detail.detailNum;
                if (codeState == 1) {
                    if (appealVal == "") {
                        toastrCog.error("请输入原因！！！", 3000)
                        return;
                    } else {
                        appealNote = appealVal;
                    }
                } else {
                    if (proVal == "") {
                        toastrCog.error("请输入原因！！！", 3000)
                        return;
                    } else {
                        proNote = proVal;
                    }
                }
                $this.parents("li").find(".appealBtn").hide();
                b.html(rule.getState(codeState));
                if (codeState == 1) {
                    $this.parents("li").find("b").show().html("已添加到申诉列表").css({"top": "4px"});
                    $("#appealAllBtn .detail-badge").show().html(parseInt($("#appealAllBtn .detail-badge").html()) + 1);
                } else if (codeState == 4) {
                    $("#appealModal").modal("show");
                } else {
                    $("#appealAllBtn .detail-badge").show().html(parseInt($("#appealAllBtn .detail-badge").html()) + 1);
                    if(codeState == 2 || codeState == 3){
                        b.html("已添加到复检列表");
                    }
                }
                $this.parents("li").find(".appBtns").append('<button class="btn btn-primary backBtn" data-code="' + codeState + '">撤销</button>');

                var oneData = {
                    serialNumber: $("#serialNumber").html(),
                    workName: $("#workName").html(),
                    ruleId: ruleId,
                    ruleName: ruleName,
                    useFor: useFor,
                    proNote: proNote,
                    appealNote: appealNote,
                    proStatus: codeState,
                    detailNum: detailNum,
                    codeState: codeState,
                    modelId: modelId,
                    voiceSegments: voiceSegments
                };
                rule.appealData.push(oneData);
                $("#tableAppeal").bootstrapTable("load", rule.appealData);
                var obj={};
                obj.ruleId=ruleId;
                obj.detailNum=detailNum;
                obj.appealNote=li.find(".appealRemark input").val();
                obj.proNote=li.find(".proRemark input").val();
                if(codeState=="1"){
                    obj.proStatus=4;
                }else  if(codeState=="2" || codeState=="3"){
                    obj.proStatus=5;
                }
                rule.updataSaveData(obj)
                // }
            })
        },
        appealAll: function () {
            $("#appealAllBtn").on("click", function () {
                $("#appealModal").modal("show");
            });
        },
        delAppeal: function (row) {
            var li = $("li[data-detailNum='" + row.detailNum + "'][data-ruleId='" + row.ruleId + "']");
            if (row.codeState != 4) {
                $("#appealAllBtn .detail-badge").show().html(parseInt($("#appealAllBtn .detail-badge").html()) - 1);
            }
            li.find(".backBtn").hide();
            li.find(".appealBtn").show();
            for (var i = 0; i < rule.appealData.length; i++) {
                var id = rule.appealData[i].detailNum;
                if (id == row.detailNum) {
                    rule.appealData.splice(i, 1);
                }
            }
            $(".detail-badge").each(function () {
                if ($(this).html() == 0) {
                    $(this).hide();
                }
            });
            $("#tableAppeal").bootstrapTable("load", rule.appealData);
            var obj={};
            obj.ruleId= row.ruleId;
            obj.detailNum=row.detailNum;
            obj.appealNote=row.appealNote;
            obj.proNote=row.proNote;
            if(row.codeState==1){
                obj.proStatus=0;
            }else if(row.codeState==2 ||row.codeState==3){
                obj.proStatus=1;
            }
            var proStatus=rule.getState(obj.proStatus);
            if(proStatus=="未申诉"){
                proStatus="";
            }
            li.find("b").html(proStatus).css({"top": "1px"});
            obj.codeStatus="";
            rule.updataSaveData(obj)
        },
        appealTableRefresh: function () {
            $("#tableAppeal").bootstrapTable("refresh");
        },
        tableRefresh: function () {
            $("#table").bootstrapTable("refresh");
            tools.getScore();
        },
        submitAppeal: function () {
            $("#submitBtn").on("click", function () {
                if (rule.appealData.length < 1) {
                    toastrCog.error("没有可提交的数据！", 3000);
                    return
                }else{
                    if ($("#userIdentity").text() != 0) {
                        if(rule.appealData.length!=rule.ruleAllData){
                            toastrCog.error("还有未处理申诉项！", 3000);
                            return
                        }
                    }
                }
                $("#submitModal").modal("show");
            });
            $("#lastSubmitBtn").on("click", function () {
                $("#lastSubmitBtn").html("请求中...请稍后").prop("disabled",true);
                var map = {},
                    dest = [];
                for (var i = 0; i < rule.appealData.length; i++) {
                    var ai = rule.appealData[i];
                    if (!map[ai.ruleId]) {
                        dest.push({
                            ruleId: ai.ruleId,
                            dats: [ai]
                        });
                        map[ai.ruleId] = ai;
                    } else {
                        for (var j = 0; j < dest.length; j++) {
                            var dj = dest[j];
                            if (dj.ruleId == ai.ruleId) {
                                dj.dats.push(ai);
                                break;
                            }
                        }
                    }
                }
                $.ajax({
                    type: "post",
                    url: basePath + "/rest/pending-task-detail/update-rules-sys",
                    dataType: "json",
                    async: false,
                    data: {
                        workId: $("#workId").html(),
                        serialNumber: $("#serialNumber").html(),
                        resMap: JSON.stringify(dest)
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            toastrCog.success(data.msg, 1000);
                            rule.appealData = [];
                            getData.getWorkStatusAll();
                            $("#tableAppeal").bootstrapTable("load", rule.appealData);
                            rule.appealTableRefresh();
                            rule.tableRefresh();
                            $("#appealModal").modal("hide");
                            $("#submitModal").modal("hide");
                            $(".detail-badge").hide().html(0);
//                                申诉完 实时更新待办任务 列表
                            setTimeout(function () {
                                if(parent.$(".J_mainContent").find("iframe[name='iframe001']").length>0){
                                    parent.$(".J_mainContent").find("iframe[name='iframe001']")[0].contentWindow.tools.tableRefresh();
                                }
                                parent.$(".J_mainContent").find("iframe[name='iframe0']")[0].contentWindow.getData.init();
                            }, 1000)
                            $("#lastSubmitBtn").html("确定").prop("disabled",false);
                        } else {
                            toastrCog.error(data.msg, 3000);
                            $("#lastSubmitBtn").html("确定").prop("disabled",false);
                            $("#submitModal").modal("hide");
                        }
                    }
                })
            })
        },
        personTest: function () {
            $("#ppBtn").on("click", function () {
                var arr = rule.getCheckedStt();
                if (arr.length <= 0) {
                    toastrCog.error("请选择语料！", 3000)
                    return
                }
                $(".tab1").show();
                $(".tab2").hide();
                // $("#jstree").jstree('select_node', $("#workId").text(), true);
                $("#jstree").jstree("deselect_all", true);
                $("#ruleS").val('');
                $("#searchMenu").prev().val('');
                var oTable2 = new TableInit2();
                oTable2.Init();
            });
            $("#selectModel").on("click", function () {
                var arr = rule.getCheckedStt();
                var selectArr = rule.selectRuleArr;
                // if (selectArr.length <= 0) {
                //     toastrCog.error("请选择规则！", 3000);
                //     return;
                // }
                if (arr.length <= 0) {
                    toastrCog.error("请选择语料！", 3000);
                    return;
                }
                if(selectArr.length>0){
                    $("#ruleCheckName").html('已选规则名称为:'+selectArr[0].ruleName);
                }else{
                    $("#ruleCheckName").html('没有选择任何规则！');
                }

                $("#ruleCheckModal").modal('show');
            })
            $("#ruleCheckBtn").on("click", function () {
                var arr = rule.getCheckedStt();
                var selectArr = rule.selectRuleArr;
                var ids = "";
                var ruleids = "";
                var ruletypeids = "";
                if(selectArr.length>0){
                    for (var i = 0; i < selectArr.length; i++) {
                        ids += selectArr[i].modelId + ",";
                        ruleids += selectArr[i].ruleId + ",";
                        ruletypeids += selectArr[i].ruleTypeId + ",";
                    }
                    ids = ids.substr(0, ids.length - 1);
                    ruleids = ruleids.substr(0, ruleids.length - 1);
                    ruletypeids = ruletypeids.substr(0, ruletypeids.length - 1);
                }
                $.ajax({
                    type: "post",
                    url: basePath + "/rest/pending-task-detail/add-rules-arti",
                    dataType: "json",
                    data: {
                        serialNumber: $("#serialNumber").html(),
                        workId: $("#workId").html(),
                        modelId: ids,
                        ruleId: ruleids,
                        ruleTypeId: ruletypeids,
                        proNote: "",
                        resMap: JSON.stringify(arr)
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            toastrCog.success(data.msg, 1000);
                            rule.tableRefresh();
                            rule.selectRuleArr = [];
                        } else {
                            toastrCog.error(data.msg, 3000);
                        }
                        rule.selectRuleArr = [];
                        $(".tab2").show();
                        $(".tab1").hide();
                        $(".checked_img.on").removeClass("on");
                        $("#ruleCheckModal").modal('hide');
                    }
                })
            })
        },
        getCheckedStt: function () {
            var checkedP = $(".checked_img.on");
            var arr = [];
            if (checkedP.length > 0) {
                checkedP.each(function () {
                    var li = $(this).parents("li");
                    var start = li.attr("data-sTime");
                    var end = li.attr("data-eTime");
                    arr.push({
                        startTime: start,
                        endTime: end
                    });
                });
            }
            return arr;
        },
        delRuleOne: function () {
            $("#table").on("click", ".delRule", function () {
                var detail = JSON.parse($(this).parents("li").attr("data-detail"));
                var code = $(this).attr("data-code");
                var modelId = detail.modelId;
                var detailNum = detail.detailNum;
                var ruleId = $(this).parents("li").attr("data-ruleid");
                $("#ruleDelModal").modal("show").attr({
                    "data-detailNum": detailNum,
                    "data-code": code,
                    "data-ruleId": ruleId,
                    "data-modelId": modelId
                });
                if (code == "5") {
                    $("#delNameRule").html("确实要删除该条命中规则");
                    $("#ruleDelModal .modal-title").html("删除规则");
                } else if (code == "4") {
                    $("#delNameRule").html("确实该条命中规则属于系统误判");
                    $("#ruleDelModal .modal-title").html("系统误判");
                }

            });
            $("#delRuleBtn").on("click", function () {
                var code = $("#ruleDelModal").attr("data-code");
                var type = ""
                if (code == "5") {
                    type = "del";
                } else if (code == "4") {
                    type = "judge";
                }
                $.ajax({
                    type: "post",
                    url: basePath + "/rest/pending-task-detail/del-judge-rules-arti",
                    dataType: "json",
                    data: {
                        serialNumber: $("#serialNumber").html(),
                        ruleId: $("#ruleDelModal").attr("data-ruleId"),
                        detailNum: $("#ruleDelModal").attr("data-detailNum"),
                        postType: type,
                        modelId:$("#ruleDelModal").attr("data-modelId"),
                        workId: $("#workId").html()
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            toastrCog.success(data.msg, 1000);
                            rule.tableRefresh();
                        } else {
                            toastrCog.error(data.msg, 3000);
                        }
                        $("#ruleDelModal").modal("hide");
                    }
                })

            })
        },
        resetRuleSearch: function () {
            $("#resetModel").on("click", function () {
                $("#jstree").jstree("deselect_all", true);
                $("#jstree").jstree('select_node', $("#workId").text(), true);
                $("#modelS").val("");
                $("#ruleS").val("");
                $("#modelTableWin").bootstrapTable('refresh');
            })
        },
        closeRule: function () {
            $("#closeRule").on("click", function () {
                $(".tab1").hide();
                $(".tab2").show();
                rule.selectRuleArr = [];
                rule.tableRefresh();
            })
        }
    };
    // 质检规则表格
    var TableInit = function () {
        var oTableInit = new Object();
        var url = basePath + "/rest/pending-task-detail/get-rule-list";
        //初始化Table
        oTableInit.Init = function () {
            $('#table').bootstrapTable({
                url: url,         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oTableInit.queryParams,//传递参数（*）
                responseHandler: function (res) {
                    tools.scoreTotal = 0;
                    tools.ruleTimesTotal = 0;
                    tools.fateful = 0;
                    tools.noFateful = 0;
                    if (res.code != 0) {
                        toastrCog.error(res.msg, 3000)
                    }
                    if(res.data.length>0){
                        $("#modelName").html("&nbsp;&nbsp;模型名称：" + res.data[0].modelName);
                        var numAll=0;
                        var userIdArr = [];
                        for(var i=0;i<res.data.length;i++){
                            if(res.data[i].ruleDetails){
                                var detail=res.data[i].ruleDetails;
                                for(var j=0;j<detail.length;j++){
                                    var  proStatus=detail[j].proStatus;
                                    var  processedInfos=detail[j].processedInfos;
                                    if(processedInfos && processedInfos.length>0){
                                        for(var n=0;n<processedInfos.length;n++){
                                            var proUserId=processedInfos[n].proUserId;
                                            if(proUserId){
                                                if(userIdArr.indexOf(proUserId)==-1){
                                                    userIdArr.push(proUserId);
                                                }
                                            }
                                        }
                                    }
                                    if(proStatus==1){
                                        numAll++;
                                    }
                                }
                            }
                        }
                        rule.ruleAllData=numAll;
                        rule.saveRuleData=res.data;
                        rule.userMsgArr = bs.getUserAccount(userIdArr.join(','));
                    }
                    return {
                        "total": res.data.length,//总页数
                        "rows": res.data   //数据
                    };
                },
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: false,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: true,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                onClickRow: function (row, tr) {
                    tr.find(".detail-icon").click();
                },
                onResetView:function(){
                    if(rule.isOpen){
                        $("#table thead tr th:last").html('<a href="javascript:;" class="detail-icon" style="margin-left: 8px;" title="全部收起"><i class="glyphicon glyphicon-chevron-up"></i></a>');
                    }else{
                        $("#table thead tr th:last").html('<a href="javascript:;" class="detail-icon" style="margin-left: 8px;" title="全部展开"><i class="glyphicon glyphicon-chevron-down"></i></a>');
                    }
                },
                columns: [
                    {
                        title: '序号',//标题  可不加
                        width: 60,
                        formatter: function (value, row, index) {
                            return (index + 1) + "";
                        }
                    },
                    {
                        field: 'modelName',
                        title: '质检模型名称',
                        visible: false,
                    },
                    {
                        field: 'ruleName',
                        title: '质检规则名称'
                    },
                    {
                        field: 'useFor',
                        title: '属性',
                        formatter: function (value, row, index) {
                            var str = "";
                            if (value == 0) {
                                str = "系统"
                            } else {
                                str = "人工"
                            }
                            return str;
                        }
                    }, {
                        field: 'fateful',
                        title: '致命性',
                        formatter: function (value, row, index) {
                            var str = "";
                            if (value == 0) {
                                str = "否"
                                tools.noFateful++;
                            } else  if (value == 1) {
                                str = "是"
                                tools.fateful++;
                            }
                            return str;
                        }
                    }, {
                        field: 'ruleTimes',
                        title: '命中量',
                        formatter: function (value, row, index) {
                            var isHave = 0;
                            var back = 0;
                            var data = row.ruleDetails;
                            var ruleTimes = row.ruleTimes;
                            for (var i = 0; i < data.length; i++) {
                                var status = data[i].proStatus;
                                if (status != 0) {
                                    isHave++;
                                }
                            }
                            var str = "";
                            if (isHave == 0) {
                                str = value;
                            } else {
                                str = "<span style='color:#e21a1a'>" + isHave + "</span>" + "/" + ruleTimes;
                            }
                            tools.ruleTimesTotal += value;
                            return '<a>' + str + '</a>';

                        }
                    }, {
                        field: 'ruleScore',
                        title: '分值',
                        formatter: function (value, row, index) {
                            return value;
                        }
                    }
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                    $("#ruleHit").find("span").html(tools.ruleTimesTotal);
                    $("#lethality").find("span").html(tools.fateful);
                    $("#noLethality").find("span").html(tools.noFateful);
                    $(".detail i").attr("class","glyphicon glyphicon-chevron-down");
                    $("tbody .detail-icon").on("click", function () {
                        var tr = $(this).parents("tr");
                        if (tr.hasClass("active")) {
                            tr.removeClass("active");
                        } else {
                            tr.addClass("active");
                        }
                        var num=0;//点击tody的icon时 如果全部展开了改变总按钮改为展开状态 如果全部收起了改变总按钮改为收起状态
                        $("tbody .detail-icon").each(function(){
                            if($(this).find("i").hasClass("glyphicon-chevron-up")){
                                num++;
                            }else{
                                num--;
                            }
                            if(num!=0){
                                if(Math.abs(num)==data.total){
                                    if(num>0){
                                        rule.isOpen=true;
                                        $("#table thead tr th:last").html('<a href="javascript:;" class="detail-icon" style="margin-left: 8px;" title="全部收起"><i class="glyphicon glyphicon-chevron-up"></i></a>');
                                    }else  if(num<0){
                                        rule.isOpen=false;
                                        $("#table thead tr th:last").html('<a href="javascript:;" class="detail-icon" style="margin-left: 8px;" title="全部展开"><i class="glyphicon glyphicon-chevron-down"></i></a>');
                                    }
                                }
                            }
                        })
                    })
                },
                onLoadError: function () {  //加载失败时执行
                    $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                },      //注册加载子表的事件。你可以理解为点击父表中+号时触发的事件
                onExpandRow: function (index, row, $detail) {
                    //这一步就是相当于在当前点击列下新创建一个table
                    if (rule.saveRuleData.length > 0) {
                        var data = rule.saveRuleData[index].ruleDetails;
                        var explainBox = $('<div class="explainBox">' +
                            '<ul>' +

                            '</ul>' +
                            '</div>');
                        for (var i = 0; i < data.length; i++) {
                            var proStatus = data[i].proStatus;
                            var appealNote = base.isNull(data[i].appealNote);
                            var proNote = base.isNull(data[i].proNote);
                            var appealTime = base.isNull(data[i].appealTime);
                            var proTime = base.isNull(data[i].proTime);
                            var state = rule.getState(proStatus);
                            var voiceSegments = data[i].voiceSegments;
                            var detailNum = data[i].detailNum;
                            var matchStatus = data[i].matchStatus;
                            var isMissing = data[i].isMissing;
                            var processed = row.processed;
                            var codeState=data[i].codeState;//前台状态控制
                            var processedInfos=data[i].processedInfos;
                            var li = "";
                            // 如果是未申诉则不显示这个状态
                            li = $('<li>' +
                                '<div class="ruleBox">命中时间：' +
                                '</div>' +
                                '<div class="handleBox">' +
                                '<div class="inputs"></div>' +
                                '<div class="appBtns"><b>' + state + '</b></div>' +
                                '</div>' +
                                '<div class="appealList">' +
                                '</div>' +
                                '</div>' +
                                '</li>');
                            // 申诉记录列表
                            var appealList=li.find(".appealList");
                            var proStatusAll="";//用来存放申诉状态 如果有一个申诉成功 则坐席不能申诉;
                            if(processedInfos && processedInfos.length>0){
                                appealList.append('<div class="appealT">申诉记录<span class="appealChange glyphicon glyphicon-chevron-up"></span></div>');
                                appealList.append('<div class="appealListBox"></div>');
                                var appealListBox =li.find(".appealListBox");
                                for (var j = 0; j < processedInfos.length; j++) {
                                    var appealNoteSub = base.isNull(processedInfos[j].appealNote);
                                    var appealTimeSub = base.isNull(processedInfos[j].appealTime);
                                    var proNoteSub = base.isNull(processedInfos[j].proNote);
                                    var proTimeSub = base.isNull(processedInfos[j].proTime);
                                    var proUserId = base.isNull(processedInfos[j].proUserId);
                                    var proStatusSub=rule.getState(processedInfos[j].proStatus);
                                    proStatusAll+=processedInfos[j].proStatus;
                                    appealListBox.prepend('<div class="appealOne">' +
                                        '<div class="appealUp"><span>申诉说明：<input type="text" disabled value="'+appealNoteSub+'"></span><span class="appealS">'+proStatusSub+'</span><span>'+appealTimeSub+'</span></div>' +
                                        '<div class="appealDown"><span>复检说明：<input type="text" disabled value="'+proNoteSub+'"></span><span class="appealS">'+bs.getXInY(rule.userMsgArr,'username','id',proUserId)+'</span><span>'+proTimeSub+'</span></div>' +
                                        '</div>');
                                }
                            }
                            // 添加命中时间
                            var ruleBox = li.find(".ruleBox");
                            for (var j = 0; j < voiceSegments.length; j++) {
                                var startTime = voiceSegments[j].startTime;
                                var endTime = voiceSegments[j].endTime;
                                ruleBox.append('<span class="ruleTime" data-sTime="' + startTime + '" data-eTime="' + endTime + '"><i class="fa fa-volume-up"></i>' + base.formatSeconds(startTime) + '-' + base.formatSeconds(endTime) + '</span></div>');
                            }
                            var proStatusText=$("#proStatus").text();
                            if ($("#userIdentity").text() !=0) {//非坐席人员
                                if (proStatus == 0) {//人工质检
                                    if (isMissing == "1") {
                                        li.find(".appBtns b").hide();
                                        if($("#ppBtn").length!=0 && $("#ppBtn").css('display') !='none'){
                                            li.find(".inputs").append("人工质检：");
                                            li.find(".appBtns").append('<button class="btn btn-primary delRule" data-code="5">删除</button>');
                                        }
                                    } else {
                                        if (matchStatus == "0") {
                                            li.find(".appBtns b").hide();
                                            if($("#ppBtn").length!=0 && $("#ppBtn").css('display') !='none'){
                                                li.find(".inputs").append("人工判断：");
                                                li.find(".appBtns").append('<button class="btn btn-primary delRule" data-code="4">系统误判</button>');
                                            }
                                        } else {
                                            li.find(".appBtns b").show().html("已纠正错误");
                                        }
                                    }
                                }
                                else {
                                    if(state == "申诉成功" || state == "申诉驳回"){
                                        li.find(".handleBox b").html("");
                                    }
                                    if(proStatus == 1 || proStatus == 5){
                                        li.find(".inputs").append('<div><span class="appealRemark">申诉说明：<input type="text" value="' + appealNote + '" title="'+appealNote+'"></span></div>');
                                        li.find(".inputs").append('<div><span class="proRemark">复检说明：<input type="text" value="' + proNote + '" title="'+proNote+'"></span></div>');
                                        li.find(".appealRemark input").attr("disabled", true);
                                        if($("#appealAllBtn").css('display') !='none'){
                                            if (proStatus == 1) {//坐席已申诉，质检员还未复检
                                                li.find(".appBtns").append('<button class="btn btn-primary appealBtn" data-code="2">同意</button><button class="btn btn-primary appealBtn" data-code="3">驳回</button>');
                                            }else if(proStatus == 5){//质检员提交复检 前台临时状态
                                                li.find(".appBtns").append('<button class="btn btn-primary appealBtn" data-code="2" style="display: none">同意</button><button class="btn btn-primary appealBtn" style="display: none" data-code="3">驳回</button>');
                                                li.find(".appBtns").append('<button class="btn btn-primary backBtn" data-code="'+codeState+'">撤销</button>');
                                            }
                                        }else{
                                            li.find(".proRemark input").attr("disabled", true);
                                        }
                                    }
                                }
                            }
                            else if ($("#userIdentity").text() ==0){//坐席
                                if(state == "未申诉" || state == "申诉成功" ||  state == "申诉驳回"){
                                    li.find(".handleBox b").html("");
                                }
                                if(matchStatus == "0" && proStatusAll.indexOf("2")==-1){//如果全部是申诉失败 则还可以继续申诉
                                    li.find(".inputs").append('<div><span class="appealRemark">申诉说明：<input type="text" value="' + appealNote + '" title="'+appealNote+'"></span></div>');
                                    li.find(".inputs").append('<div class="hidden"><span class="proRemark">复检说明：<input type="text" value="' + proNote + '" title="'+proNote+'"></span></div>');
                                    li.find(".proRemark input").attr("disabled", true);
                                    if(proStatus != 1){
                                        li.find(".appBtns").append('<button class="btn btn-primary appealBtn" data-code="1">申诉</button>');
                                    }
                                    if(proStatus == 4){
                                        li.find(".appBtns").find("button").remove();
                                        li.find(".appBtns").append('<button class="btn btn-primary appealBtn" data-code="1" style="display: none;">申诉</button>');
                                        li.find(".appBtns").append('<button class="btn btn-primary backBtn" data-code="'+codeState+'">撤销</button>');
                                    }
                                }
                                if(state == "已申诉"){
                                    li.find(".appealRemark input").attr("disabled", true);
                                    li.find(".handleBox").append('<span>'+appealTime+'</span>');
                                }
                                if($("#appealAllBtn").css('display') =='none'){//任务过期
                                    li.find(".proRemark input").attr("disabled", true);
                                    li.find(".appealRemark input").attr("disabled", true);
                                    li.find(".appBtns").find("button").remove();
                                }
                            }
                            data[i].codeState = li.find(".appealBtn").attr("data-code");
                            data[i].modelId = row.modelId;
                            var jsonStr = JSON.stringify(data[i]);

                            li.attr("data-detail", jsonStr);
                            li.attr("data-ruleId", row.ruleId);
                            li.attr("data-ruleName", row.ruleName);
                            li.attr("data-useFor", row.useFor);
                            li.attr("data-detailNum", detailNum);
                            explainBox.find("ul").append(li);
                        }
                        $detail.html(explainBox); // 关键地方
                    }
                    $detail.find(".proRemark input").on("blur",function(){
                        var $li=$(this).parents("li");
                        var ruleId=$li.attr("data-ruleId");
                        var detailNum=$li.attr("data-detailNum");
                        var detail=JSON.parse($li.attr("data-detail"));
                        var obj={};
                        obj.ruleId=ruleId;
                        obj.detailNum=detailNum;
                        obj.appealNote=detail.appealNote;
                        obj.proNote=$(this).val();
                        $(this).attr("title",$(this).val());
                        rule.updataSaveData(obj)
                    });
                    $detail.find(".appealRemark input").on("blur",function(){
                        var $li=$(this).parents("li");
                        var ruleId=$li.attr("data-ruleId");
                        var detailNum=$li.attr("data-detailNum");
                        var detail=JSON.parse($li.attr("data-detail"));
                        var obj={};
                        obj.ruleId=ruleId;
                        obj.detailNum=detailNum;
                        obj.appealNote=$(this).val();
                        obj.proNote=detail.proNote;
                        $(this).attr("title",$(this).val());
                        rule.updataSaveData(obj)
                    });
                    $detail.find(".appealChange").on("click",function(){
                        if($(this).hasClass("glyphicon-chevron-up")){
                            $(this).removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
                            $(this).parent().next().slideUp();
                        }else{
                            $(this).removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
                            $(this).parent().next().slideDown();
                        }
                    });
                }
            });
        };
        //得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                workId: $("#workId").html(),
                serialNumber: $("#serialNumber").html()
            };
            return temp;
        };
        return oTableInit;
    };
    // 提交申诉/复检表格
    var TableInit1 = function () {
        var oTableInit1 = new Object();
        //初始化Table
        oTableInit1.Init = function () {
            $('#tableAppeal').bootstrapTable({
                data: rule.appealData,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                columns: [
                    {
                        field: 'modelName',
                        title: '语音段',
                        width: '150px',
                        formatter: function (value, row, index) {
                            var arr = row.voiceSegments;
                            var str = "";
                            for (var i = 0; i < arr.length; i++) {
                                var start = arr[i].startTime;
                                var end = arr[i].endTime;
                                str += base.formatSeconds(start) + " - " + base.formatSeconds(end) + "<br>"
                            }
                            return str;
                        }
                    },
                    {
                        field: 'ruleName',
                        title: '规则名称'
                    },
                    {
                        field: 'useFor',
                        title: '规则属性',
                        formatter: function (value, row, index) {
                            var str = "";
                            if (value == 0) {
                                str = "系统"
                            } else {
                                str = "人工"
                            }
                            return str;
                        }
                    }, {
                        field: 'appealNote',
                        title: '申诉说明'
                    }, {
                        field: 'proNote',
                        title: '复检说明'
                    },
                    {
                        field: 'proStatus',
                        title: '处理状态',
//                        visible:false,
                        formatter: function (value, row, index) {
                            var color = "#000";
                            var str = "";
                            if (value == 3) {
                                color = "#e8554f";
                                str = "已驳回";
                            } else if (value == 2) {
                                color = "#1d9a70";
                                str = "已同意";
                            }
                            return "<span style='color:" + color + "'>" + str + "</span>";
                        }
                    },
                    {
                        field: 'Button',
                        title: '操作',
                        formatter: function (value, row, index) {
                            return [
                                '<a href="javascript:;" class="fa fa-trash  handleBtn" title="删除"  ></a>'
                            ]
                        },
                        events: {
                            'click .handleBtn': function (e, value, row, index) {
                                rule.delAppeal(row);
                            }
                        }
                    }
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    if (!data.total || data.total == 0) {
                        $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
//                    toastr.error('加载数据失败！');
                    $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                }      //注册加载子表的事件。你可以理解为点击父表中+号时触发的事件
            });
        };
        return oTableInit1;
    };
    // 人工质检规则的左侧树
    var menu = {
        init: function () {
            menu.render($("#workId").text());
            menu.changeMenu();
            menu.search();
        },
        render: function (node) {
            var jstree = $("#jstree");
            jstree.jstree({
                "core": {
                    "animation": false,
                    "multiple": false,
                    "check_callback": true,
                    'data': function (obj, callback) {
                        var jsonstr = "[]";
                        $.ajax({
                            type: "post",
                            url: basePath + 'rest/pending-task-detail/get-rule-tree',
                            dataType: "json",
//                            async: false,
                            data: {
                                workId: $("#workId").html()
                            },
                            success: function (data) {
                                var result = data.data;
                                if(result.length!=0){
                                    result=data.data.children[0].children
                                    result.unshift({
                                        'children':[],
                                        'id':'',
                                        'text':'全部',
                                        'type':'html'
                                    })
                                }
                                if (result != null) {
                                    callback.call(this, menu.loopMenu(result));
                                }
                            }
                        });
                    }
                },
                "types": {
                    "default": {
                        "icon": "jstree-folder"
                    },
                    "html": {
                        "icon": "jstree-file"
                    }
                },
                "plugins": ["types", "search", "unique"]
            }).bind('loaded.jstree', function (e, data) {
                jstree.jstree("deselect_all", true);
                var obj = jstree.jstree("get_node", node);
                jstree.jstree('select_node', obj, true);
                $("li[aria-selected='true']").click();
            })
        },
        rootLoopMenu: function (array, obj) {
            if (array.length > 0) {
                var parentid = obj.parentid;
                for (var i = 0; i < array.length; i++) {
                    var code = 0;
                    var id = array[i]["id"];
                    if (parentid == id) {
                        array[i]["children"].push(obj);
                        return array;
                    } else {
                        code++;
                    }
                    if (code == array.length) {
                        for (var j = 0; j < code; j++) {
                            menu.rootLoopMenu(array[j]["children"], obj);
                        }
                    }
                }
                return array;
            }
        },
        loopMenu: function (array) {
            if (array && array.length > 0) {
                for (var i = 0; i < array.length; i++) {
                    var children = array[i]["children"];
                    if (children && children.length <= 0) {
                        array[i].type = "html"
                    } else {
//                        if(i<=1){
                        array[i].state = {"opened": "true", "type": array[i].type}
//                        }
                    }
                    if (children) {
                        menu.loopMenu(children);
                    }
                }
                return array;
            } else {
                return []
            }
        },
        changeMenu: function () {
            $('#jstree').on("changed.jstree", function (e, data) {
                if (data.node) {
                    var type = data.node.original.type;
                    if (type == "task") {
                        $("#modelS").val("");
                        $("#ruleS").val("");
                    } else if (type == "model") {
                        $("#modelS").val(data.selected);
                        $("#ruleS").val("");
                    } else {
                        $("#modelS").val("");
                        $("#ruleS").val(data.selected);
                        if(data.selected == 'j1_1'){
                            $("#ruleS").val('');
                        }
                    }
                    $("#modelTableWin").bootstrapTable('refresh');
                }

            });
        },
        search: function () {
            $("#searchMenu").on("click", function () {
                $('#modelTableWin').bootstrapTable("refresh");
            });
        },
    };
    // 人工质检规则的表格
    var TableInit2 = function () {
        var oTableInit2 = new Object();
        var url = basePath + "rest/pending-task-detail/get-rule-by-tree";
        //初始化Table
        oTableInit2.Init = function () {
            $('#modelTableWin').bootstrapTable("destroy");
            $('#modelTableWin').bootstrapTable({
//                toolbar: '#tools_bar',                //工具按钮用哪个容器
                url: url,         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                responseHandler: function (res) {
                    json = res.data;
                    var arr1 = rule.getCheckedStt();
                    $.ajax({
                        type: "post",
                        url: basePath + "/rest/pending-task-detail/is-rules-exit",
                        dataType: "json",
                        async:false,
                        data: {
                            workId: $("#workId").html(),
                            serialNumber: $("#serialNumber").html(),
                            resMap: JSON.stringify(arr1)
                        },
                        success: function (data) {
                            rule.hasRuleArr=[];
                            if (data.code == 0) {
                                var selArr=data.data;
                                if(selArr.length>0 && json.length>0){
                                    for(var m=0;m<json.length;m++){
                                        for(var n=0;n<selArr.length;n++){
                                            if(json[m].ruleId==selArr[n]){
                                                rule.hasRuleArr.push(json[m]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    });
                    var selectArr = rule.selectRuleArr;
                    var hasArr = rule.hasRuleArr;
                    var arr = res.data;
                    if(arr.length > 0){
                        for (var i = 0; i < arr.length; i++) {
                            arr[i]["state"] =false;
                            arr[i]["has"] =false;
                        }
                    }
                    if (selectArr.length > 0 && arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            for (var j = 0; j < selectArr.length; j++) {
                                if (selectArr[j]["ruleId"] == arr[i]["ruleId"]) {
                                    arr[i]["state"] = true;
                                }
                            }
                        }
                    }
                    if (hasArr.length > 0 && arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            for (var j = 0; j < hasArr.length; j++) {
                                if (hasArr[j]["ruleId"] == arr[i]["ruleId"]) {
                                    arr[i]["has"] = true;
                                }
                            }
                        }
                    }
                    return {
                        "total": res.count,//总页数
                        "rows": arr  //数据
                    };
                },
                pagination: true, // 是否显示分页（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 10,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                contentType: "application/x-www-form-urlencoded",
                strictSearch: true,
                showColumns: false,                  //是否显示所有的列
                showRefresh: false,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                singleSelect: true,                //是否启用点击选中行
                uniqueId: "no",                     //每一行的唯一标识，一般为主键列
                showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                cellStyle: {
                    css: {"background-color": "#fff"}
                },//是否显示父子表
                queryParams: function (params) {

                    var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        pageNum: params.offset/params.limit,   //页面大小
                        pageSize: params.limit,
                        workId: $("#workId").text(),
                        modelId: $("#modelS").val(),
                        ruleTypeId: $("#ruleS").val(),
                        ruleName:$.trim($("#searchMenu").prev().val())
                    };
                    return temp;
                },
                columns: [
                    {
                        checkbox: true, // 显示一个勾选框
                        align: 'center', // 居中显示
                        formatter: function (value, row, index) {
                            var obj={};
                            if (row.state == true){
                                obj.checked=true;
                            }else{
                                obj.checked=false;
                            }
                            if (row.has == true){
                                obj.disabled=true;
                            }else{
                                obj.disabled=false;
                            }
                            return obj;
                        }
                    },
                    {
                        title: '序号',//标题  可不加
                        field: 'id',
                        width: 60,
                        formatter: function (value, row, index) {
                            var getOptions = $("#modelTableWin").bootstrapTable('getOptions');
                            var pagenum = getOptions.pageNumber;
                            var pagesize = getOptions.pageSize;
                            var st = (pagenum - 1) * pagesize;
                            return (st + index + 1) + "";
                        }
                    },
                    {
                        field: 'ruleName',
                        title: '规则名称'
                    },
                    {
                        field: 'userFor',
                        title: '规则属性',
                        formatter: function (value, row, index) {
                            var str = "";
                            if (value == "0") {
                                str = "系统"
                            } else if (value == "1") {
                                str = "人工"
                            }
                            return str;
                        }
                    }, {
                        field: 'fateful',
                        title: '致命性',
                        formatter: function (value, row, index) {
                            var  str = ''
                            if (value == 0) {
                                str = "否"
                            } else  if (value == 1) {
                                str = "是"
                            }
                            if(row.signScore == 1) {
                                return ''
                            }else{
                                return str;
                            }
                        }
                    }, {
                        field: 'scorePerTime',
                        title: '单次分值',
                        formatter: function (value, row, index) {
                            if(row.fateful == 1){
                                return '--'
                            }else{
                                if(value === 0){
                                    if(row.signscore != 1){
                                        value = '-'+ value
                                    }
                                }
                                return value
                            }
                        }
                    }, {
                        field: 'maxScore',
                        title: '分值上限',
                    },
                ],
                onLoadSuccess: function (data) {  //加载成功时执行
                    resize.me();
                    if (!data.total || data.total == 0) {
                        $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                    }
                },
                onLoadError: function () {  //加载失败时执行
//                    toastr.error('加载数据失败！');
                    $(".no-records-found").find("td").html('<img src="../../../assert/image/nodata.png" th:src="@{/assert/image/nodata.png}" style="width:165px;" alt="">');
                },
                onCheck: function (row, tr) {
                    rule.selectRuleArr = []
                    rule.selectRuleArr.push(row)
                },
                onUncheck: function (row, tr) {
                    rule.selectRuleArr = []
                },
                onResetView: function (data) {
                    var arr=$("#modelTableWin").bootstrapTable('getData');
                    for(var i=0;i<arr.length;i++){
                        if(arr[i]['has']){
                            if(arr[i]['userFor']=="1"){
                                $("#modelTableWin").find("tbody tr").eq(i).addClass("trDisabledY")
                            }else{
                                $("#modelTableWin").find("tbody tr").eq(i).addClass("trDisabled")
                            }
                        }
                    }
                },
                formatLoadingMessage: function () {
                    return '<div class="loaded">' +
                        '<div class="loader">' +
                        '<div class="loader-inner line-scale-pulse-out">' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '<div></div>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '<div>请稍等，数据正在加载中...</div>';
                },
            });
        };
        return oTableInit2;
    };

    $(function () {
        getData.init();
        wave.init();
        tools.init();
        base.init();
        stt.init(true);
        tag.init();
        rule.init();
        menu.init();
        if(getData.jumpType=="audio"){
            $(".noPer").hide()
        }
        setTimeout(function(){
            resize.init();
        },200)
    })
</script>
</body>
</html>